package net.caidingke.shepherd.utils.constant;

import com.google.common.base.Joiner;
import com.google.common.base.Splitter;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeUnit;

/**
 * @author bowen.
 */
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class Const {

    public static final Splitter SPLITTER = Splitter.on(",");

    public static final Joiner JOINER = Joiner.on(",").skipNulls();

    public static final String NOT_FOUND = "NOT FOUND";

    public static final String ADMIN = "ROLE_ADMIN";

    public static final String USER = "ROLE_USER";

    public static final String ANONYMOUS = "ROLE_ANONYMOUS";

    public static final String COOKIE = "SHEPHERD-REMEMBER-ME";

    public static final String KEY = "0ffe67a93df996928658d5ae40da9b25b1f2992e";

    public static final String CACHE_PREFIX = "SHEPHERD_";

    public static void main(String[] args) throws InterruptedException {
        CompletableFuture
                //委托师傅做蛋糕
                .supplyAsync(() -> {
                    try {
                        System.out.println("师傅准备做蛋糕");
                        TimeUnit.SECONDS.sleep(10);
                        System.out.println("师傅做蛋糕做好了");
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    return "cake";
                })
                //做好了告诉我一声
                .thenAccept(cake -> {

                    System.out.println("我吃蛋糕:" + cake);
                });
        System.out.println("我先去喝杯牛奶");
        Thread.currentThread().join();
    }
}
